package cn.woblog.recyclerviewsample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import cn.woblog.recyclerviewsample.divider.CustomDividerItemDecoration;
import java.util.ArrayList;

public class ListDividerActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_divider);

    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

    //使用自带的分割线
//    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
//        LinearLayoutCompat.VERTICAL);
//    rv.addItemDecoration(dividerItemDecoration);
//    dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.item_divider));
//    rv.setLayoutManager(new LinearLayoutManager(this));

//垂直
    CustomDividerItemDecoration dividerItemDecoration = new CustomDividerItemDecoration(this,
        DividerItemDecoration.VERTICAL);
//dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.item_divider) );
    rv.addItemDecoration(dividerItemDecoration);
    rv.setLayoutManager(new LinearLayoutManager(this));

//    CustomDividerItemDecoration dividerItemDecoration = new CustomDividerItemDecoration(this,
//        DividerItemDecoration.HORIZONTAL);
////dividerItemDecoration.setDrawable(getResources().getDrawable(R.drawable.item_divider) );
//    rv.addItemDecoration(dividerItemDecoration);
//    rv.setLayoutManager(new LinearLayoutManager(this,DividerItemDecoration.HORIZONTAL,false));

//水平
//    rv.addItemDecoration(new CustomDividerItemDecoration(this, LinearLayoutCompat.HORIZONTAL));
//    rv.setLayoutManager(new LinearLayoutManager(this,LinearLayoutCompat.HORIZONTAL,false));

//    TextView textView = new TextView(this);
//    textView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,80));
//    rv.addView(textView,0);

    UseCustomAdapter useCustomAdapter = new UseCustomAdapter(this);
    rv.setAdapter(useCustomAdapter);

    ArrayList<String> data = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
      data.add("Item " + i);
    }

    useCustomAdapter.setData(data);


  }
}
